#pragma once

#include <gofcl_timer_event.h>
#include <gofcl_timer_r.h>

typedef struct {
	timer_event_s IF;
	timer_event_s OF;
} __attribute__((aligned(2))) timer_intf_s;

_Static_assert(sizeof(timer_intf_s) == 2, "Struct timer_intf_s defined error!");

static inline void timer_wreg_intf_s(timer_qe timer_q, timer_intf_s intf) {
	union {
		timer_intf_s i;
		u16_s u;
	} iu = {
		.i = intf,
	};
	timer_wreg_u16(timer_q, TIMER_INTF_R, T16B_0_R, iu.u);
}

static inline timer_intf_s timer_rreg_intf_s(timer_qe timer_q) {
	union {
		timer_intf_s i;
		u16_s u;
	} iu = {
		.u = timer_rreg_u16(timer_q, TIMER_INTF_R, T16B_0_R),
	};
	return iu.i;
}
